//package com.lill.system.config;
//
//import java.util.LinkedHashMap;
//import java.util.Map;
//
//import javax.servlet.Filter;
//
//import org.apache.shiro.spring.LifecycleBeanPostProcessor;
//import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
//import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
//import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
//import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
//import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.boot.autoconfigure.AutoConfigureAfter;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.DependsOn;
//
//import com.lill.org.service.ICompanyBranchService;
//import com.lill.system.dao.ISysMenuDao;
//import com.lill.system.dao.ISysUserDao;
//
//@Configuration
//@AutoConfigureAfter({BusinessSystemDataSourceConfig.class,CommonRedisConfig.class,ISysUserDao.class,ISysMenuDao.class,CluterShiroSessionDao.class,ShiroSessionFilter.class,UserShiroRealm.class,ICompanyBranchService.class})
//public class ShiroConfig {
//	
//	@Bean(name="sessionManager")
//	public DefaultWebSessionManager setWebSessionManager(@Qualifier("cluterShiroSessionDao") CluterShiroSessionDao sessionDao){
//		DefaultWebSessionManager webSessionManager=new DefaultWebSessionManager();
//		webSessionManager.setGlobalSessionTimeout(3600000L);
//		webSessionManager.setSessionValidationSchedulerEnabled(true);
//		webSessionManager.setSessionIdUrlRewritingEnabled(false);
//		webSessionManager.setSessionDAO(sessionDao);
//		return webSessionManager;
//	}
//	
//	@Bean(name="securityManager")
//	public DefaultWebSecurityManager setDefaultWebSecurityManager(@Qualifier("userRealm") UserShiroRealm userRealm,
//			@Qualifier("sessionManager") DefaultWebSessionManager sessionManager){
//		DefaultWebSecurityManager webSecurityManager=new DefaultWebSecurityManager();
//		webSecurityManager.setSessionManager(sessionManager);
//		webSecurityManager.setRealm(userRealm);
//		return webSecurityManager;
//	}
//	
//	@Bean(name="shiroFilter")
//	public ShiroFilterFactoryBean setShiroFilterFactoryBean(@Qualifier("securityManager") DefaultWebSecurityManager securityManager,
//			@Qualifier("shiroSessionFilter") ShiroSessionFilter shiroSessionFilter){
//		ShiroFilterFactoryBean filterFactoryBean=new ShiroFilterFactoryBean();
//		filterFactoryBean.setSecurityManager(securityManager);
//		
//		Map<String, Filter> filterMap = new LinkedHashMap<>();
//        filterMap.put("shiroSessionFilter", shiroSessionFilter);
//        filterFactoryBean.setFilters(filterMap);
//        
//        filterFactoryBean.setLoginUrl("/login.html");
//        filterFactoryBean.setSuccessUrl("/index.html");
//        filterFactoryBean.setUnauthorizedUrl("/");
//        
//        Map<String, String> filterChainDefinitions = new LinkedHashMap<>();
//        filterChainDefinitions.put("/statics/**","anon");
//        filterChainDefinitions.put("/api/**","anon");
//        filterChainDefinitions.put("/login.html","anon");
//        filterChainDefinitions.put("/doc.html","anon");
//        filterChainDefinitions.put("/v2/**","anon");
//        filterChainDefinitions.put("/swagger-resources/**","anon");
//        filterChainDefinitions.put("/webjars/**","anon");
//        filterChainDefinitions.put("/sys/login","anon");
//        filterChainDefinitions.put("/captcha.jpg","anon");
//        filterChainDefinitions.put("/**","authc");
//        filterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitions);
//		
//		return filterFactoryBean;
//	}
//	
//	@Bean(name="lifecycleBeanPostProcessor")
//	public LifecycleBeanPostProcessor setLifecycleBeanPostProcessor(){
//		return new LifecycleBeanPostProcessor();
//	}
//	
//	@Bean
//	@DependsOn("lifecycleBeanPostProcessor")
//	public DefaultAdvisorAutoProxyCreator setDefaultAdvisorAutoProxyCreator(){
//		DefaultAdvisorAutoProxyCreator proxyCreator=new DefaultAdvisorAutoProxyCreator();
//		proxyCreator.setProxyTargetClass(true);
//		return proxyCreator;
//	}
//	
//	@Bean
//	public AuthorizationAttributeSourceAdvisor setAuthorizationAttributeSourceAdvisor(
//			@Qualifier("securityManager") DefaultWebSecurityManager securityManager){
//		AuthorizationAttributeSourceAdvisor sourceAdvisor=new AuthorizationAttributeSourceAdvisor();
//		sourceAdvisor.setSecurityManager(securityManager);
//		return sourceAdvisor;
//	}
//	
//}
